package com.blindbugs.boletus;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
 
public class BoletusSQLiteHelper extends SQLiteOpenHelper {
 
    public BoletusSQLiteHelper(Context context, String name,
			CursorFactory factory, int version) {
		super(context, name, factory, version);
		
	}

	String sqlCreate = "CREATE TABLE [findings] (" + 
						"[id] INTEGER  NOT NULL PRIMARY KEY AUTOINCREMENT,"+
						"[description] TEXT  NULL,"+
						"[latitude] NUMERIC  NULL,"+
						"[longitude] NUMERIC  NULL)";
 
    
 
    @Override
    public void onCreate(SQLiteDatabase db) {
      
        db.execSQL(sqlCreate);
//        insertFinding(db, "bolet 1", 41672912, 1989899);
//        insertFinding(db, "bolet 2", 41296381, 1842957);
//        insertFinding(db, "bolet 3", 41573334, 2106628);
    }
 
    @Override
    public void onUpgrade(SQLiteDatabase db, int versionAnterior, int versionNueva) {
       
    }
    
    public long insertFinding(SQLiteDatabase db, String description, int latitude, int longitude)
    {
    	ContentValues cv=new ContentValues();
    	cv.put("description", description);
    	cv.put("latitude", latitude);
    	cv.put("longitude", longitude);
    	return db.insert("findings", null, cv);
    }
    public Cursor getFindings(SQLiteDatabase db)
    {
    	return db.query("findings", new String[] {"description","latitude","longitude"}, "", null, null, null, null);
    }
    
}
